package Operation;

import Books.Book;
import Books.Booklist;

import java.util.Scanner;

public class Borrwbook implements IOPeration{
    @Override
    public void work(Booklist booklist) {
        System.out.println("借阅图书");
        System.out.println("请输入你要借阅的图书名称");
        Scanner scanner=new Scanner(System.in);
        String name= scanner.nextLine();
        int n=booklist.getUsersize();
        for(int i=0;i<n;i++){
            Book book=booklist.getbook(i);
            if(book.getBname().equals(name)){//是否找到该书籍
                if(book.isBrorrowed()){
                    System.out.println("你要找的书，已被借阅");
                }
                else {
                    book.setBrorrowed(true);
                    System.out.println("借阅成功");
                    System.out.println(book);
                }
                return;
            }
        }
        System.out.println("没有你要找的书，无法借阅");
    }
}
